package org.koalaui.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

/**
 * Servlet implementation class GridDataServlet
 */
public class GridDataServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private final Logger logger = Logger.getLogger(GridDataServlet.class); 
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GridDataServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String json = "{\"limit\":10,\"Rows\":[{\"id\":2,\"version\":0,\"createDate\":\"2013-12-13 10:39:35\",\"abolishDate\":\"8888-01-01 00:00:00\",\"name\":\"operator\",\"serialNumber\":\"test\",\"sortOrder\":0,\"createOwner\":null,\"roleDesc\":\"操作员\",\"valid\":false}],\"start\":0,\"Total\":1}";
		logger.info("返回数据：" + json);
		
		response.setContentType("text/xml;charset=UTF-8");  
		response.setHeader("Cache-Control", "no-cache");  
		PrintWriter out = response.getWriter();
		out.write(json);
		out.flush();
		out.close();
	}

}
